<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a>{$title}</a></li>
    </ul>
    <form class="well form-inline margin-top-20" method="post" action="{:url($controller.'/index')}">
        名称:
        <input type="text" class="form-control" name="name" style="width: 120px;" value="{:input('request.name')}" placeholder="请输入名称">
        <input type="submit" class="btn btn-primary" value="搜索" />
        <a class="btn btn-danger" href="{:url($controller.'/index')}">清空</a>
        <span style="float:right">
               <a class="btn btn-success"  href='javaScript:' id="add">
                   添加{$title}
               </a>
        </span>
    </form>
    <form action="" method="post" class="margin-top-20">
        <table class="table table-hover table-bordered">
            <thead>
            <tr class="success">
                <th width="10%">序号</th>
                <th width="15%">名称</th>
                <th width="15%">创建时间</th>
                <th width="15%">状态</th>
                <th width="15%">{:lang('ACTIONS')}</th>
            </tr>
            </thead>
            <tbody>
                <notempty name="data">
                    <volist name="data" id="vo">
                        <tr class="danger">
                            <td>{:$i}</td>
                            <td>{:$vo.name}</td>
                            <td>{:date('Y-m-d H:i:s',$vo['time'])}</td>
                            <td>
                                <switch name="vo.status">
                                    <case value="1">
                                        {:lang('ENABLED')}
                                    </case>
                                    <case value="2">
                                        {:lang('DISABLED')}
                                    </case>
                                    <default/>
                                    未知状态
                                </switch>
                            </td>
                            <td>
                                <switch name="vo.status">
                                    <case value="1">
                                        <a class="js-ajax-dialog-btn"
                                           data-msg="你确定要{:lang('DISABLED')}"
                                           href="{:url($controller.'/update',array('id'=>$vo['id'],'status'=>2))}">{:lang('DISABLED')}</a>
                                    </case>
                                    <case value="2">
                                        <a class="js-ajax-dialog-btn"
                                           data-msg="你确定要{:lang('ENABLED')}"
                                           href="{:url($controller.'/update',array('id'=>$vo['id'],'status'=>1))}">{:lang('ENABLED')}</a>
                                    </case>
                                    <default/>
                                    未知状态
                                </switch>
                                <a href="javaScript:"  name="change">{:lang('EDIT')}</a>
                                <a href="{:url($controller.'/delete',array('id'=>$vo['id']))}" class="js-ajax-delete">
                                    {:lang('DELETE')}
                                </a>
                            </td>
                            <input type="hidden" value="{$vo.id}">
                        </tr>

                    </volist>
                </notempty>
            </tbody>
        </table>
    </form>
    <div class="pagination">{$page|default=''}</div>
</div>


<!--添加弹窗-->
<div class="modal fade"  id="myModal"
     tabindex="-1"
     role="dialog"
     aria-labelledby="myModalLabel">

    <div class="modal-dialog"
         role="document">

        <div class="modal-content">

            <div class="modal-header">

                <button type="button"
                        class="close"
                        data-dismiss="modal"
                        aria-label="Close"><span
                        aria-hidden="true">×</span></button>

                <h4 class="modal-title">添加{$title}</h4>

            </div>

            <form action="{:url($controller.'/addPost')}" method="post" class="js-ajax-form">

                <div class="modal-body">

                    <div class="form-group">

                        <label for="name">名称</label>

                        <input type="text"
                               name="name"
                               class="form-control"
                               id="name"
                               placeholder="名称" required>

                    </div>
                </div>

                <div class="modal-footer">

                    <button type="button"
                            class="btn btn-default"  data-dismiss="modal">
                        <!--<span
                            class="glyphicon glyphicon-remove"  aria-hidden="true"></span>-->
                        关闭</button>
                    <button type="submit"
                            class="btn btn-primary  js-ajax-submit" >
							<span class="glyphicon glyphicon-floppy-disk"  aria-hidden="true">

							</span>
                        添加
                    </button>

                </div>

            </form>


        </div>

    </div>

</div>
<!--添加弹窗-->


<!--修改弹窗-->
<div class="modal fade"  id="myModal2"
     tabindex="-1"
     role="dialog"
     aria-labelledby="myModalLabel">

    <div class="modal-dialog"
         role="document">

        <div class="modal-content">

            <div class="modal-header">

                <button type="button"
                        class="close"
                        data-dismiss="modal"
                        aria-label="Close"><span
                        aria-hidden="true">×</span></button>

                <h4 class="modal-title">修改{$title}</h4>

            </div>

            <form action="{:url($controller.'/editPost')}" method="post" class="js-ajax-form">
                <input type="hidden" name="id" id="payment_id">
                <div class="modal-body">

                    <div class="form-group">

                        <label for="payment_name">名称</label>

                        <input type="text"
                               name="name"
                               class="form-control"
                               id="payment_name"
                               placeholder="名称">

                    </div>
                </div>

                <div class="modal-footer">

                    <button type="button"
                            class="btn btn-default"  data-dismiss="modal">
                        <!--<span
                            class="glyphicon glyphicon-remove"  aria-hidden="true"></span>-->
                        关闭</button>
                    <button type="submit"
                            class="btn btn-primary  js-ajax-submit" >
							<span class="glyphicon glyphicon-floppy-disk"  aria-hidden="true">

							</span>
                        修改
                    </button>

                </div>

            </form>


        </div>

    </div>

</div>
<!--修改弹窗-->
<script src="__STATIC__/js/admin.js"></script>

<script>
    $("#add").click(function () {
        $('#myModal').modal();
    });

    $('[name="change"]').click(function () {
        var thisTd =  $(this).parent();
        $('#payment_id').val(thisTd.next().val());
        $('#payment_name').val(thisTd.parent().children().eq(1).text());
        $('#myModal2').modal();
    });
</script>
</body>
</html>